programming4us
           
 
 
Windows

Windows 7 Customization : Working with Existing File Types

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019
10/30/2010 11:42:11 AM

In this section, you’ll learn how to work with Windows 7’s existing file types. I’ll show you how to change the file type description, modify the file type’s actions, associate an extension with another file type, and disassociate a file type and an extension. Note that earlier versions of Windows had a decent front-end for these types of hacks: the File Types tab in the Folder Options dialog box. Alas, that tab is nowhere in sight in Windows 7, so you must use the Registry directly for some of what follows.

Setting the Default Action

Many file types have a default action that Windows 7 runs when you double-click a document of that file type. You can see the default action by right-clicking a document and examining the shortcut menu for the command that appears in bold type. You can edit the Registry to change the default action for a file type. Why would you want to do this? Here are some examples:

  • For HTML documents (.htm or .html extension), the default action is Open, which opens the document in Internet Explorer. If you hand-code HTML pages, you might prefer the default action to be Edit so that you can quickly load the documents in your text editor.

  • For images, the default action is Preview, which opens images in the Photo Gallery Viewer. Again, if you work with images frequently (creating them, cropping them, converting them, and so on), you might prefer that Edit be the default action.

  • For Windows Scripting Host file types, such as VBScript Script File (.vbs extension) and JScript Script File (.js extension), the default action is Open, which runs the script. However, these scripts can contain malicious code, so you can boost the security of your system by changing the default action for these file types to Edit.

To change the default action for a file type, follow these steps:

1.
Open the Registry Editor.

2.
Navigate to the key associated with the file type you want to work with.

3.
Open the key and click the Shell branch.

4.
Double-click the Default value to open the Edit String dialog box.

5.
Type the name of the action that you want to be the default. For example, if you want the Edit action to be the default, type Edit.

6.
Click OK.

Figure 1 shows the VBSFile file type (VBScript Script File) with the Shell branch’s Default setting changed to Edit.

Figure 1. To change a file type’s default action, change the value of the Shell branch’s Default setting.


Tip

When you want to open a folder window in the two-paned Explorer view, you have to right-click the folder and then click Explore. To make the latter the default action for a folder, edit the Folder file type, select Explore in the Actions list, and then click Set Default.


Creating a New File Type Action

You’re not stuck with just the actions that Windows 7 has defined for a file type. You can add as many new actions that you can think of. For example, if you work with HTML documents, you could keep the default Edit action as it is (this opens the file for editing in Notepad) and create a new action—called, for example, Open in HTML Editor—that opens the file in an HTML editor that you have installed. When you right-click an HTML file, the menu that appears will show both commands: Edit (for Notepad) and Open in HTML Editor (for the other editor; note that, for simplicity’s sake, I’m assuming here that when you installed the HTML editor, it didn’t modify the Edit action to point to itself).

To create a new action for an existing file type, follow these steps:

1.
Open the Registry Editor.

2.
Navigate to the key associated with the file type you want to work with.

3.
Open the key and click the Shell branch.

4.
Select Edit, New, Key, type the name of the new action, and press Enter.

5.
Select Edit, New, Key, type command, and press Enter.

6.
In the command branch, double-click the Default value to open the Edit String dialog box.

7.
Type the full pathname of the application you want to use for the action. Here are some notes to bear in mind:

  • If the pathname of the executable file contains a space, be sure to enclose the path in quotation marks, like so:

    "C:\Program Files\My Program\program.exe"
  • If you’ll be using documents that have spaces in their filenames, add the %1 parameter after the pathname:

    "C:\Program Files\My Program\program.exe" "%1"
The %1 part tells the application to load the specified file (such as a filename you click), and the quotation marks ensure that no problems occur with multiple-word filenames.

  • If you’re adding a Print action, be sure to include the /p switch after the application’s pathname, like this:

    "C:\Program Files\My Program\program.exe" /p

Tip

You can define an accelerator key for the new action. Click the branch that holds the action name, and then double-click the Default value. In the Edit String dialog box, type the action name and precede a letter with an ampersand (&). That letter will be the menu accelerator key. For example, entering Open in &HTML Editor defines H as the accelerator key. When you right-click a file of this type, you can then press H to select the command in the shortcut menu.

8.
Click OK.

Example: Opening the Command Prompt in the Current Folder

When you’re working in Windows Explorer, you might occasionally find that you need to do some work at the Command Prompt. For example, the current folder might contain multiple files that need to be renamed—a task that’s most easily done within a command-line session. Selecting Start, All Programs, Accessories, Command Prompt starts the session in the %UserProfile% folder, so you have to use one or more CD commands to get to the folder you want to work in.

An easier way would be to create a new action for the Folder file type that launches the Command Prompt and automatically displays the current Windows Explorer folder. To do this, follow these steps:

1.
Open the Registry Editor.

2.
Navigate to the Folder key.

3.
Open the key and click the shell branch.

4.
Select Edit, New, Key, type Open with Command Prompt, and press Enter.

5.
Select Edit, New, Key, type command, and press Enter.

6.
In the command branch, double-click the Default value to open the Edit String dialog box.

7.
Type the following:

cmd.exe /k cd "%L"

Note

The cmd.exe file is the Command Prompt executable file. The /k switch tells Windows 7 to keep the Command Prompt window open after the CD (change directory) command completes. The %L placeholder represents the full pathname of the current folder.

8.
Click OK. Figure 2 shows the Registry Editor with the new Open with Command Prompt action added to the HKCR\Folder\shell key.

Figure 2. Modify the HKCR\Folder\shell key to define a new action for the Folder file type.


In Figure 3, I right-clicked a folder, and you can see that the new action appears in the shortcut menu.

Figure 3. After you add the new action to the file type’s shell key, the action appears in the file type’s shortcut menu.


Hiding a File Type’s Extension

A shortcut is a file that points to another object: a document, folder, drive, printer, and so on. Shortcuts use the .lnk extension, which is associated with the lnkfile file type. Strangely, if you turn on file extensions, you still never see the .lnk extension when you view a shortcut file. Presumably, Windows 7 hides the extension because we’re not supposed to think of the shortcut as an actual file, just a pointer to a file. That’s fine with me, but how does Windows 7 accomplish the trick of always hiding a shortcut’s file extension?

The secret is that the Registry’s lnkfile (shortcut) key has an empty string setting named NeverShowExt. When Windows 7 comes across this setting, it always hides the file type’s extension.

You might want to duplicate this effect for another file type. If you have multiple users on your computer, for example, you might want to turn on file extensions, but hide the extensions of an important file type to ensure that users can’t change it. Follow these steps to always hide a file type’s extension:

1.
Open the Registry Editor.

2.
Navigate to the key of the file type you want to work with.

3.
Select Edit, New, String Value.

4.
Type NeverShowExt and press Enter.

Associating an Extension with a Different Application

There are many reasons you might want to override Windows 7’s default associations and use a different program to open an extension. For example, you might prefer to open text files in WordPad instead of Notepad. Similarly, you might want to open HTML files in Notepad or some other text editor rather than Internet Explorer.

In those cases, you need to associate the extension with the application you want to use instead of the Windows default association. In Windows 7, you use the Open With dialog box to change the associated application, and Windows 7 gives you many different ways to display this dialog box:

  • Right-click— With this method, right-click any file that uses the extension and then click Open With. If the file type already has multiple programs associated with it, you’ll see a menu of those programs. In this case, click the Choose Default Program command from the menu that appears.

  • Task pane— When you click a file, Windows Explorer’s task pane displays a button that represents the default action for the file type. For example, if you click an image, a Preview button appears in the task pane; if you click an audio file, you see a Play button in the task pane. In most cases, this default action button also doubles as a drop-down list. Display the list and click Choose Default Program.

  • Set associations— Select Start, Default Programs, Associate a File Type or Protocol with a Program. This opens the Set Associations window, shown in Figure 4, which displays a list of file extensions. Click the file type you want to work with and then click Change Program.

    Figure 4. Use the Set Associations dialog box to change the application associated with any of the displayed file extensions.

No matter which method you use, you end up in the Open With dialog box, shown in Figure 5. From here, you follow these steps:

1.
Select the program you want to associate with the file type. (If you don’t see the program, click Browse, use the new Open With dialog box to select the program’s executable file, and then click Open.)

2.
Make sure that the Always Use the Selected Program to Open This Kind of File check box is activated. (If you arrived at the Open With dialog box via the Set Associations window, this check box is always activated and disabled.)

3.
Click OK.

Figure 5. Use the Open With dialog box to associate a file type with a different application.


Tip

What if you want only a single file to open with a different application? For example, you might want to always edit a particular HTML file in Notepad, but still open all other HTML files with Internet Explorer. Windows 7 automatically associates just that file with the different application, so whether you open the file via the jump list or by double-clicking it, it will always default to the new application.


Associating an Application with Multiple File Types

Many applications can work with multiple file types. For example, Media Player can play more than 30 file types, including Windows Media Audio (.wma), MP3 (.mp3), CD Audio Track (.cda), and AVI (.avi). Windows 7 has a Set Default Programs window that enables you to specify which file types are associated with a particular application. Here’s how to use it:

1.
Select Start, Default Programs to display the Default Programs window.

2.
Select Set Your Default Programs to display the Set Default Programs window.

3.
Use the Programs list to select the application you want to work with.

4.
You now have two choices:

  • If you want to associate with the program all the file types that the program is capable of handling, click the Set This Program as Default button.

  • If you want to associate with the program only some of the file types that is can handle, click Choose Defaults for This Program to display the Set Program Associations window. Activate the check box for each file type you want to associate with the program, and then click Save.

5.
Click OK.
Other -----------------
- Windows 7 Customization : Understanding File Types
- Windows Azure Service Life Cycle
- Backing Up and Restoring with ntbackup
- Windows Azure Service Management
- Windows Azure : Content Delivery Network
- Windows Azure Storage Services
- Windows Azure Storage Characteristics
- Microsoft Windows Vista : Using Parental Controls to Restrict Computer Usage
- Microsoft Windows Vista : Creating and Enforcing Bulletproof Passwords
- Windows 7 Customization : Taking Ownership of Your Files
- Windows 7 Customization : Stopping Delete Confirmations
- Windows 7 : Managing a User Account - Limiting Computer Access
- Windows 7 : Managing a User Account
- Windows 7 : Understanding User Accounts and Permissions
- Windows Azure : Diagnostics
- Windows Azure : Common Storage Tasks - Utilizing Concurrent Updates
- Windows Azure : Common Storage Tasks - Modeling Data
- Windows Azure : Exploring Full-Text Search (part 3)
- Windows Azure : Exploring Full-Text Search (part 2) - Building an FTS Engine on Azure
- Windows Azure : Exploring Full-Text Search (part 1) - Indexing
 
 
 
Top 10
 
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
- First look: Apple Watch

- 3 Tips for Maintaining Your Cell Phone Battery (part 1)

- 3 Tips for Maintaining Your Cell Phone Battery (part 2)
programming4us programming4us